<!-- 需求：打开页面1秒后，打印hello world，再过1秒打印hello vue，再过1秒打印“结束” -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //以前的方法
        // setTimeout(() => {
        //     console.log('hello world');
        //     setTimeout(() => {
        //         console.log('hello vue');
        //         setTimeout(() => {
        //             console.log('结束');

        //         }, 1000)
        //     }, 1000)
        // }, 1000)


        //用promise的方案
        new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve()
            }, 1000)
        }).then(() => {
            console.log('hello world');

            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve()
                }, 1000)
            })
        }).then(() => {
            console.log('hello vue');

            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve()
                }, 1000)
            })
        }).then(() => {
            console.log('结束');
        })
    </script>
</body>

</html>